#ifndef template_match
#define template_match

#include "stdafx.h";
#include "highgui.h";
#include "cv.h";
#include <iostream>
#include <stdio.h>
#include <conio.h>;
#include <cxcore.h>;

using namespace std;
using namespace cv;



class TemplateMatch{

public:
	Mat Image, Template, WorkImage, Result;
	Mat source, target, tempSource, colorImage;
	bool DrawContour;

	TemplateMatch()
	{};

	void TemplateMatch::findCentre();

	void loadImage(const string& filename, const string& tempfile);

	void TemplateMatch::LoadLiveFeed(const string& tempfile);

	bool FastMatchTemplate(const Mat&      source,
		const Mat&      target,
		vector<Point>*  foundPointsList,
		vector<double>* confidencesList,
		int             matchPercentage = 70,
		bool            findMultipleTargets = true,
		int             numMaxima = 100,
		int             numDownPyrs = 2,
		int             searchExpansion = 15);

	void MultipleMaxLoc(const Mat& image,
		Point**    locations,
		int        numMaxima);


	void DrawFoundTargets(Mat* image,
		const Size&            size,
		const vector<Point>&   pointsList,
		const vector<double>&  confidencesList,
		int                    red   = 0,
		int                    green = 255,
		int                    blue  = 0);

	void Match();


private:
	double minVal, maxVal; 
	Point minLoc, maxLoc, matchLoc, Centre;
	Vec3b pixelElement;

};

#endif